package com.leyou.item.dto;

import lombok.Data;

import java.util.List;
import java.util.Map;

/**
 * HuGe
 */
@Data
public class CategoryRootDTO {

    private Long id;
    private String name;
    private List<CategoryTwoLevelDTO> categoryTwoLevels;

    public CategoryRootDTO(Long id, String name, List<CategoryTwoLevelDTO> categoryTwoLevels) {
        this.id = id;
        this.name = name;
        this.categoryTwoLevels = categoryTwoLevels;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<CategoryTwoLevelDTO> getCategoryTwoLevels() {
        return categoryTwoLevels;
    }

    public void setCategoryTwoLevels(List<CategoryTwoLevelDTO> categoryTwoLevels) {
        this.categoryTwoLevels = categoryTwoLevels;
    }

    public static CategoryRootDTO ofDTO(Category category, List<Category> levelTwoDTO, Map<Long,List<Category>> subDTOs) {

        return new CategoryRootDTO(category.getId(),category.getName(),CategoryTwoLevelDTO.ofDTOs(levelTwoDTO,subDTOs));
    }
}